package com.myaxuan;

import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;


@SpringBootApplication
@EnableDiscoveryClient
@EnableCircuitBreaker
@EnableFeignClients


public class SpringCloudProducerApplication {
	
	/**
	 * hystrix 仪表盘 初始化操作
	 * 在spring-boot-starter-parent 2.0.0.RELEASE
	 *   spring-cloud-starter-parent Finchley.M8
	 * 版本要看仪表盘需要做初始化操作.2.0.0之前不需要
	 * @return
	 */
	@Bean
	public ServletRegistrationBean getServlet(){
		HystrixMetricsStreamServlet streamServlet=new HystrixMetricsStreamServlet();
		ServletRegistrationBean registrationBean=new ServletRegistrationBean(streamServlet);
		registrationBean.setName("HystrixMetricsStreamServlet");
		registrationBean.addUrlMappings("/hystrix.stream");
		registrationBean.setLoadOnStartup(1);
		return registrationBean;
	}
	
	public static void main(String[] args) {
		SpringApplication.run(SpringCloudProducerApplication.class, args);
	}
}
